# $Id: PKGBUILD 89875 2013-05-04 04:07:03Z fyan $
# Maintainer: Felix Yan <felixonmars@gmail.com>
# Contributor:  Yangtse Su<yangtsesu@gmail.com>
# Contributor:  Jekyll Wu<adaptee [at] gmail [dot] com>
# Contributor: riverscn<riverscn at gmail.com>
# Contributor: rainy<rainylau at gmail.com>
# Contributor: Lee.MaRS<leemars at gmail.com>

pkgname=ibus-libpinyin
pkgver=1.6.91
pkgrel=1
pkgdesc="Intelligent Pinyin engine based on libpinyin for IBus"
arch=('i686' 'x86_64')
license=('LGPL')
url="https://github.com/libpinyin/ibus-libpinyin"
depends=('ibus' 'libpinyin')
makedepends=('git' 'intltool' 'gnome-common')
source=(https://github.com/libpinyin/ibus-libpinyin/archive/$pkgver.tar.gz
	automake-1.13.patch)

build() {
  cd "$srcdir"
  rm -rf "$srcdir/$pkgname-build"
  cp -r "$srcdir/$pkgname-$pkgver" "$srcdir/$pkgname-build"
  cd "$srcdir/$pkgname-build"

  patch -Np1 -i "$srcdir/automake-1.13.patch"

  msg "Starting make..."
  cd "$srcdir/$pkgname-build"

  # python2 fix
  for file in $(find . -name '*.py' -print); do
    sed -i 's_^#!.*/usr/bin/python_#!/usr/bin/python2_' $file
    sed -i 's_^#!.*/usr/bin/env.*python_#!/usr/bin/env python2_' $file
  done

  for file in setup/ibus-setup-libpinyin.in; do
    sed -i 's_exec python_exec python2_' $file
  done

  export REQUIRED_AUTOMAKE_VERSION=1.13 automake_progs=automake-1.13

  ./autogen.sh --prefix=/usr --libexecdir=/usr/lib/$pkgname
  make
}

package() {
  cd "$srcdir/$pkgname-build"
  make NO_INDEX=true DESTDIR="$pkgdir" install
}

sha512sums=('6e1fb4f1fe3c5c6c37e60c8228b79728c388ffd171b68cea87bc2131e27430cdad6eff174a41111cb0694559f6307be3578ea1c960629bbfc99c41f4dbfc344e'
            'fbb30cddd1ec140860ce0d5a5a42ad644ae6a1794fb2e805f782fdb43436ad13d2f6f8149b5b68540bbb9beba16dbbdb1d14153cef7fb805de342a8d1bb77965')
